package cn.iocoder.yudao.module.enterprise.service.praxisAnnex;

import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.enterprise.controller.admin.praxisProject.vo.EnterpriseAnnexVO;
import cn.iocoder.yudao.module.enterprise.dal.dataobject.praxisAnnex.EnterpriseAnnexDO;
import cn.iocoder.yudao.module.enterprise.dal.mysql.praxisAnnex.EnterpriseAnnexMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

/**
 * 项目附件 Service 实现类
 *
 * @author 管理员
 */
@Service
@Validated
public class EnterpriseAnnexServiceImpl implements EnterpriseAnnexService {

    @Resource
    private EnterpriseAnnexMapper enterpriseAnnexMapper;


    @Override
    public List<EnterpriseAnnexDO> getPraxisAnnexList(EnterpriseAnnexVO exportReqVO) {
        return enterpriseAnnexMapper.selectList(exportReqVO);
    }

    @Override
    public List<EnterpriseAnnexVO> getPraxisAnnexListByProjectId(Long relationId, Integer relationType) {
        return enterpriseAnnexMapper.getPraxisAnnexListByProjectId(relationId,relationType);
    }

    @Override
    public void batchSavePraxisAnnex(List<EnterpriseAnnexDO> list) {
        enterpriseAnnexMapper.insertBatch(list);
    }

    @Override
    public void deletePraxisAnnexByProjectId(Long relationId,Integer relationType){
        enterpriseAnnexMapper.delete(new QueryWrapper<EnterpriseAnnexDO>().eq("relation_id",relationId)
        .eq("relation_type",relationType));
    }
}
